package IC.LIR;

public class LirInstruction{

    private String firstOperand;
    private String secondOperand;
    private InstructionType insType;

    
    /*
     * To be used for labels only
     */
    public LirInstruction(String ins){
        this.insType = null;
        this.firstOperand = ins;
        this.secondOperand = null;
    }
    
    public LirInstruction(InstructionType insType, String firstOperand, String secondOperand){
        this.insType = insType;
        this.firstOperand = firstOperand;        
        this.secondOperand = secondOperand;
    }

    public LirInstruction(InstructionType insType, String firstOperand){
        this.insType = insType;
        this.firstOperand = firstOperand;
        this.secondOperand = null;
    }

    @Override
    public String toString(){
        if (insType == null){
            return firstOperand + ":\n";            
        }
        if (secondOperand == null){
            return insType + " " + firstOperand + "\n";
        }
        else{
            return insType + " " + firstOperand + "," + secondOperand + "\n";
        }

    }
}